package com.java.sample.domain;

import java.util.Objects;

public class AdInfoTest {

    public static void main(String[] args) {
//        IAdInfoService adInfoService = new AdSystemEnvInfoServiceImpl();
        IAdInfoService adInfoService = new AdJnaInfoServiceImpl();
        // 1. 获取用户名
        String userName = adInfoService.getUserName();
        System.out.println("Username: " + userName);

        // 2. 获取计算机名
        String computerName = adInfoService.getComputerName();
        System.out.println("Computer name: " + computerName);

        // 3. 获取域名
        String domain = adInfoService.getDomain();
        System.out.println("Domain: " + domain);

        // 4. 组合信息
        if (Objects.nonNull(domain) && !domain.isEmpty() && !domain.equals(computerName)) {
            System.out.println("Domain account: " + domain + "\\" + userName);
        } else {
            System.out.println("Local account: " + computerName + "\\" + userName);
        }
    }

}
